package com.dsteiner.gwt.cafeteriasophia.client;



import com.dsteiner.gwt.cafeteriasophia.client.controller.HistoryController;
import com.dsteiner.gwt.cafeteriasophia.client.model.HistoryModel;
import com.dsteiner.gwt.cafeteriasophia.client.model.ShiftChangeInfoModel;
import com.dsteiner.widgets.client.Widgets.FlowPanelExt;
import com.dsteiner.widgets.client.Widgets.IWidget;
import com.dsteiner.widgets.client.Widgets.IWidgetBuilder;
import com.dsteiner.widgets.client.Widgets.LazyWidget;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;

public class HistoryWidget extends LazyWidget implements IWidgetBuilder{

	private HistoryController historyController = new HistoryController();
	private final HistoryModel historyModel;

	public HistoryWidget(HistoryModel historyModel) {
		this.historyModel = historyModel;
		setStyleName("history-widget");
	}

	@Override
	public Widget createContentWidget() {
		FlowPanel mainPanel = new FlowPanel();
		FlowPanelExt contentPanel = new FlowPanelExt();
		
		mainPanel.add(contentPanel);
		
		historyController.registerContentPanel(contentPanel);
		historyController.registerHistoryWidget(this);
		historyController.registerHistoryModel(historyModel);
		historyController.registerWidgetBuilder(this);
		return mainPanel;
	}

	public IWidget createWidget(Object model) {
		ShiftChangeInfoWidget widget = new ShiftChangeInfoWidget((ShiftChangeInfoModel) model, historyModel);
		return widget;
	}

}